﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tracy.DataModel;

namespace TracyGUI.UIComponent
{
    class TabPageFiles : TabPageGeneric<MediaFile>
    {
        internal TabPageFiles(string name, string text, ContextMenuStrip contextMenu)
            : base(name, text, contextMenu)
        {

        }

        protected override void InitColumns()
        {
            //TODO: load from settings
            AddColumn("Name");
            AddColumn("Type");
            AddColumn("Status");

            _listViewItems.Columns["Name"].Width = 500;
        }

        protected override ListViewItem CreateListViewItem(MediaFile dataItem)
        {
            ListViewItem lvItemMediaFile = new ListViewItem();
            lvItemMediaFile.Name = dataItem.ID;
            lvItemMediaFile.Tag = dataItem;
            lvItemMediaFile.Text = dataItem.FileName;
            AddSubListViewItem(lvItemMediaFile, "Type", dataItem.GetFileExtension());
            AddSubListViewItem(lvItemMediaFile, "Status", dataItem.Status);
            return lvItemMediaFile;
        }

        protected override void UpdateListViewItem(ListViewItem lvItem, MediaFile dataItem)
        {
            lvItem.SubItems["Status"].Text = dataItem.Status;
        }

        protected override bool IsVisiable(MediaFile dataItem)
        {
            return (dataItem.Visible == "true");
        }
    }
}
